<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实人认证结果</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
            background-color: #f5f5f5;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 2vh 20px;
        }
        .container {
            background: white;
            border-radius: 16px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
            padding: 3vh 5vw;
            max-width: min(90vw, 500px);
            width: 100%;
            text-align: center;
            animation: slideUp 0.6s ease-out;
            max-height: 96vh;
            overflow-y: auto;
        }
        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        h1 {
            color: #333;
            margin-bottom: 3vh;
            font-size: clamp(20px, 4vw, 28px);
            font-weight: 600;
        }
        .status-icon {
            width: clamp(50px, 10vw, 80px);
            height: clamp(50px, 10vw, 80px);
            margin: 0 auto 2vh;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: clamp(24px, 5vw, 40px);
            animation: pulse 2s infinite;
            border: 3px solid;
            background: white;
        }
        .success {
            color: #10b981;
            border-color: #10b981;
        }
        .failure {
            color: #ef4444;
            border-color: #ef4444;
        }
        .unknown {
            color: #f59e0b;
            border-color: #f59e0b;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        .result-info {
            background: #f9fafb;
            border-radius: 12px;
            padding: 1.5vh 3vw;
            margin: 1.5vh 0;
        }
        .info-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 1vh 0;
            padding: 0.8vh 0;
            border-bottom: 1px solid #e5e7eb;
        }
        .info-row:last-child {
            border-bottom: none;
        }
        .info-label {
            font-weight: 600;
            color: #6b7280;
            font-size: clamp(12px, 2.5vw, 14px);
        }
        .info-value {
            font-weight: 500;
            color: #374151;
            font-size: clamp(13px, 3vw, 16px);
        }
        .status-success {
            color: #10b981;
            font-weight: 600;
        }
        .status-failure {
            color: #ef4444;
            font-weight: 600;
        }
        .face-image {
            margin: 1.5vh 0 0.5vh 0;
        }
        .face-image img {
            max-width: clamp(220px, 35vw, 280px);
            width: 100%;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            border: 2px solid #f3f4f6;
            transition: transform 0.3s ease;
            cursor: pointer;
        }
        .face-image img:hover {
            transform: scale(1.02);
        }
        
        /* 图片放大查看模态框 */
        .image-modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            animation: fadeIn 0.3s ease;
        }
        .modal-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: auto;
            height: auto;
            max-width: 95vw;
            max-height: 95vh;
            min-width: 300px;
            border-radius: 12px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        }
        .modal-content img {
            width: 100%;
            height: 100%;
            max-width: none;
            max-height: none;
            object-fit: contain;
            border-radius: 12px;
            display: block;
        }
        .close-modal {
            position: absolute;
            top: 20px;
            right: 30px;
            color: white;
            font-size: 40px;
            font-weight: bold;
            cursor: pointer;
            z-index: 1001;
            background: rgba(0, 0, 0, 0.5);
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }
        .close-modal:hover {
            background: rgba(0, 0, 0, 0.7);
        }
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        .back-button {
            display: inline-block;
            padding: 12px 32px;
            background: #3b82f6;
            color: white;
            text-decoration: none;
            border-radius: 8px;
            font-weight: 600;
            font-size: 15px;
            margin-top: 1.5vh;
            min-width: 120px;
            transition: all 0.3s ease;
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
        }
        .back-button:hover {
            background: #2563eb;
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        }
        @media (max-width: 480px) {
            .container {
                padding: 3vh 4vw;
                max-width: 95vw;
            }
            .info-row {
                flex-direction: column;
                align-items: flex-start;
                gap: 0.5vh;
            }
        }
        
        /* 确保在非常小的屏幕上仍然可读 */
        @media (max-height: 600px) {
            .container {
                padding: 1.5vh 3vw;
            }
            h1 {
                margin-bottom: 1.5vh;
            }
            .status-icon {
                margin: 0 auto 1vh;
            }
            .result-info {
                margin: 0.8vh 0;
                padding: 0.8vh 2.5vw;
            }
            .face-image {
                margin: 0.8vh 0 0.3vh 0;
            }
            .back-button {
                margin-top: 0.8vh;
                padding: 10px 24px;
                font-size: 14px;
                min-width: 100px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>实人认证结果</h1>
        
        <div th:class="'status-icon ' + (${passed} == 'T' ? 'success' : (${passed} == 'F' ? 'failure' : 'unknown'))">
            <span th:text="${passed} == 'T' ? '✓' : '✗'"></span>
        </div>
        
        <div class="result-info">
            <div class="info-row">
                <span class="info-label">状态码</span>
                <span class="info-value" th:text="${code}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">消息</span>
                <span class="info-value" th:text="${msg}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">结果码</span>
                <span class="info-value" th:text="${resultCode}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">验证结果</span>
                <span th:class="'info-value ' + (${passed} == 'T' ? 'status-success' : (${passed} == 'F' ? 'status-failure' : ''))" 
                      th:text="${passed} == 'T' ? '人脸核身通过，是 ' + ${certName} + ' 本人' : (${passed} == 'F' ? '人脸核身未通过，假脸/非 '+ ${certName} +' 本人' : '未获取到验证结果')"></span>
            </div>
            <div class="info-row" th:if="${certName}">
                <span class="info-label">姓名</span>
                <span class="info-value" th:text="${certName}"></span>
            </div>
            <div class="info-row" th:if="${certNo}">
                <span class="info-label">身份证号</span>
                <span class="info-value" th:text="${certNo}"></span>
            </div>
        </div>
        
        <div class="face-image" th:if="${bestImgUrl}">
            <img th:src="${bestImgUrl}" alt="人脸识别图片" onclick="openImageModal(this)" />
        </div>
        
        <a href="https://face.eshunda.cn" class="back-button">返回官网</a>
    </div>
    
    <!-- 图片放大查看模态框 -->
    <div id="imageModal" class="image-modal" onclick="closeImageModal()">
        <span class="close-modal" onclick="closeImageModal()">&times;</span>
        <div class="modal-content">
            <img id="modalImage" src="" alt="放大查看">
        </div>
    </div>
    
    <script>
        function openImageModal(img) {
            const modal = document.getElementById('imageModal');
            const modalImg = document.getElementById('modalImage');
            modal.style.display = 'block';
            modalImg.src = img.src;
            
            // 确保图片加载后重新计算尺寸
            modalImg.onload = function() {
                const container = modalImg.parentElement;
                const imgAspectRatio = this.naturalWidth / this.naturalHeight;
                const containerMaxWidth = window.innerWidth * 0.95;
                const containerMaxHeight = window.innerHeight * 0.95;
                
                let newWidth = Math.min(this.naturalWidth, containerMaxWidth);
                let newHeight = newWidth / imgAspectRatio;
                
                if (newHeight > containerMaxHeight) {
                    newHeight = containerMaxHeight;
                    newWidth = newHeight * imgAspectRatio;
                }
                
                container.style.width = newWidth + 'px';
                container.style.height = newHeight + 'px';
            };
            
            // 阻止事件冒泡
            event.stopPropagation();
        }
        
        function closeImageModal() {
            const modal = document.getElementById('imageModal');
            modal.style.display = 'none';
        }
        
        // ESC键关闭模态框
        document.addEventListener('keydown', function(event) {
            if (event.key === 'Escape') {
                closeImageModal();
            }
        });
        
        // 点击模态框内容区域不关闭
        document.querySelector('.modal-content').addEventListener('click', function(event) {
            event.stopPropagation();
        });
    </script>
</body>
</html> 